import { observable, action } from 'mobx';

import { ListPage } from 'weaver-mobile-page';

const initDatas = {
    values: {   //流程退回选择的结果
        rejectNodeKey: "",
        remindNodeid: "",
        isSubmitDirect:"",
    },
    datas : {},//流程退回的参数
     rejectList : new ListPage.Store(),
     remindList : new ListPage.Store(),
    submitList: new ListPage.Store(),
    isHasSubmitMethod: false,
}


export class RejectChooseStore {
    @observable allData = initDatas;
    @action("获取退回方式的数据")
    doInit = (datas={}) => {
        this.allData.datas = datas;
        this.allData.rejectList.setState({ selectedRowKeys: [datas.checkedRejectNodeKey] })
        this.allData.values.rejectNodeKey = datas.checkedRejectNodeKey;
        let arr = [];
        datas.remindNodeList.map(item => {
            arr.push(item.key)
        });
        this.allData.remindList.setState({ selectedRowKeys: arr })
        this.allData.values.remindNodeid = arr.join(",");
        if (datas.submitDirectNodeOptions && datas.submitDirectNodeOptions.length <= 0) {
            this.allData.isHasSubmitMethod = false;
        } else if (datas.submitDirectNodeOptions && datas.submitDirectNodeOptions.length > 0) {
            this.allData.isHasSubmitMethod = true;
        }
        datas.submitDirectNodeOptions.map(item => {
            if (item.selected === true) {
                this.allData.submitList.setState({ selectedRowKeys: [item.key] })
                this.allData.values.isSubmitDirect = item.key;
            }
        });
    }
    @action("修改退回设置的参数")
    changeCondition = (att, val) => {
        this.allData.values[att] = val;
    }
    resetToInit=()=>{
        this.allData=initDatas;
    }
}